﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Configuration;
using System.Net;
using System.Net.Mail;

namespace MagicAclarant.WebSite
{
    public class Correo
    {
        public string EnviarCorreo(string From, string To, string Subject, string Body)
        {
            //Envío de correo - Inicio
            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
            msg.To.Add(To);
            //msg.Bcc.Add("cesarvallejo09@gmail.com");
            msg.From = new MailAddress(From, "CONTACTO MAGIC ACLARANT", System.Text.Encoding.UTF8);
            msg.Subject = Subject;
            msg.Body = Body;
            msg.IsBodyHtml = true;
            msg.Priority = MailPriority.Normal;

            SmtpClient client = new SmtpClient();

            #region Valores que vienen del App.config
            //client.Credentials = new System.Net.NetworkCredential("cesarvallejo09@gmail.com", "45110884");
            //client.Port = 587;
            //client.Host = "smtp.gmail.com";            
            #endregion

            try
            {
                client.Send(msg);
                return "Ok";
            }
            catch (System.Net.Mail.SmtpException ex)
            {
                return ex.Message;
            }
            //Envío de correo - Fin            
        }
    }
}